package TestIf;

import java.util.Scanner;

//测试if语句
public class TestIf {
    public static void main(String[] args) {
        int d=(int)(6*Math.random());//随机生成0~5的数
        int e=(int)(6*Math.random()+1);//随机生成1~6的数
        System.out.println(d);
        System.out.println(e);

        //商场打折,如果满100,减20,输出原价和打折后的价格
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入商品价格:");
        double price=scanner.nextDouble();
        System.out.println("商品原价:"+price);
        if (price>=100){
            double lastPrice=price-20;
            System.out.println("商品价格满100元,减20");
            System.out.println("打折后,实付:"+lastPrice);
        }else {
            System.out.println("商品价格不满100元,没有折扣,应付:"+price+"元");
        }


        //闰年问题案例
        System.out.print("请输入年份:");
        Scanner sc=new Scanner(System.in);
        int year=sc.nextInt();
        if ((year%4==0&&year%100!=0)||(year%400==0)){
            System.out.println(year+"是闰年!");
        }else{
            System.out.println(year+"不是闰年!");
        }

        //判断成绩
        System.out.print("请输入成绩:");
        Scanner s=new Scanner(System.in);
        int score=s.nextInt();
        if (score>=90){
            System.out.println("优");
        }else if (score>=80){
            System.out.println("良");
        }else if (score>=60){
            System.out.println("中");
        }else {
            System.out.println("不及格");
        }

        Scanner scanner2=new Scanner(System.in);
        System.out.println("请输入两个数x,y");
        System.out.print("x=");
        int x=scanner2.nextInt();
        System.out.println();
        System.out.print("y=");
        int y=scanner2.nextInt();
        if (x!=y){
            if (x>y){
                System.out.println("x>y:"+x+">"+y);
            }else {
                System.out.println("x<y:"+x+"<"+y);
            }
        }else {
            System.out.println("x=y="+x);
        }

        //判断星期
        System.out.print("请输入1-7的数字:");
        Scanner scanner1=new Scanner(System.in);
        int week=scanner1.nextInt();
        switch (week){
            case 1:
                System.out.println("星期一");
                break;
            case 2:
                System.out.println("星期二");
                break;
            case 3:
                System.out.println("星期三");
                break;
            case 4:
                System.out.println("星期四");
                break;
            case 5:
                System.out.println("星期五");
                break;
            case 6:
                System.out.println("星期六");
                break;
            case 7:
                System.out.println("星期七");
                break;
            default:
                System.out.println("请输入正确的星期格式");
                break;
        }


    }
}
